import 'package:flutter/material.dart';
import 'package:flutter_homemonitor/pages/Login.dart';

class DialogUtil {
  //退出登录
  static void showDioalog(BuildContext context) {
    NavigatorState? navigator =
        context.findRootAncestorStateOfType<NavigatorState>();
    debugPrint("navigator is null?" + (navigator == null).toString());

    showDialog(
        context: context,
        builder: (_) => new AlertDialog(
//            title: new Text("提 示"),
                content: new Text("退出当前用户",
                    style: TextStyle(
                        fontSize: 20.0,
                        color: Colors.blueAccent,
                        fontFamily: "BenMoYouYuan")),
                actions: <Widget>[
                  new TextButton(
                    child: new Text("取消",
                        style: TextStyle(
                            fontSize: 16.0,
                            color: Colors.blueAccent,
                            fontFamily: "BenMoYouYuan")),
                    onPressed: () {
                      Navigator.of(context).pop(_);
                    },
                  ),
                  new TextButton(
                    child: new Text("确定退出",
                        style: TextStyle(
                            fontSize: 16.0,
                            color: Colors.blueAccent,
                            fontFamily: "BenMoYouYuan")),
                    onPressed: () {
                      //跳转并销毁当前
                      Navigator.pushAndRemoveUntil(context,
                          new MaterialPageRoute(
                              builder: (BuildContext context) {
                        return Login();
                      }), (route) => route == Null);
                    },
                  )
                ]));
  }
}
